﻿using System;
using System.Text.RegularExpressions;
using System.Collections.ObjectModel;

namespace HobSoft.SoccerBet2014.Client.ViewModels
{
    [Serializable]
    public class Bookmaker : ViewModelBase
    {
        Regex hostRegex = new Regex(@"^([a-zA-Z0-9\-]+)(\.?]?[a-zA-Z0-9\-]+)*(:[0-9]+)?$", RegexOptions.Compiled);

        private byte _bmId;
        public byte BmID
        {
            get { return _bmId; }
            set
            {
                PropertyValueChange(ref _bmId, value, "BmID");
            }
        }

        private string _bmName;
        public string BmName
        {
            get { return _bmName; }
            set
            {
                PropertyValueChange(ref _bmName, value, "BmName");
            }
        }

        private string _defaultHost;
        public string DefaultHost
        {
            get { return _defaultHost; }
            set
            {
                if (string.IsNullOrEmpty(value) || !hostRegex.IsMatch(value))
                {
                    RaiseErrorsChanged("DefaultHost", "主机域名格式错误");
                    return;
                }
                PropertyValueChange(ref _defaultHost, value, "DefaultHost");
            }
        }

        private bool _accountUse;

        public bool AccountUse
        {
            get { return _accountUse; }
            set
            {
                PropertyValueChange(ref _accountUse, value, "AccountUse");
            }
        }
        
    }
}
